<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>按键修饰符</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <div>
        <label>用户名：</label
        ><input type="text" v-on:keyup.delete="clearName" v-model="uname" />
      </div>
      <div>
        <label>密码：</label
        ><input type="password" v-on:keyup.enter="submit" v-model="pwd" />
      </div>
      <input type="submit" value="提交" v-on:click="submit" />
    </div>

    <script>
      var vm = new Vue({
        el: '#app',
        data: {
          uname: 'zhangsanf',
          pwd: '666666',
        },
        methods: {
          clearName: function () {
            this.uname = '';
          },
          submit: function () {
            console.log(this.uname, this.pwd);
          },
        },
      });
    </script>
  </body>
</html>
